<template>
  <a-drawer
    v-model:visible="visible"
    title="添加"
    placement="right"
    width="463px"
  >
   <template #extra>
      <close-outlined  @click="close"/>
    </template>
       <school-form ref="formRef" :formData="formData"></school-form>
      <template #footer>
      <a-button style="margin-right: 8px;" @click="close">取消</a-button>
      <a-button type="primary" @click="handleOk">确定</a-button>
    </template>
  </a-drawer>
</template>
<script lang='ts' setup>
import {ref} from 'vue'
import { message} from 'ant-design-vue'
import { useModalForm } from '@/modules/use-modules'
import SchoolForm from './SchoolForm.vue';
import {add} from '@/modules/list'
const formRef =   ref<InstanceType<typeof SchoolForm>>()
const {
  formData,
  loading,
  visible,
  title,
  open,
  close
} = useModalForm({}, async (data: any) => {
  return {
    ...data,
  }
})
const emits = defineEmits(['ok','getformData'])
const handleOk = async () => {
  // await formRef.value.validate()
  // await saveUser(formData.value)
  try {
        // const values = await formRef.value?.validate();
        const res= emits('getformData')
        await add(res)
        message.success('操作成功')
        emits('ok')
        close()
        //formRef.value?.resetFields()
      } catch (errorInfo) {
        console.log('Failed:', errorInfo);
      }
}
defineExpose({ open})
</script>
<style lang='less' >
</style>